package com.gs.SynAntiWandering.presenter;

import com.google.gson.reflect.TypeToken;
import com.gs.SynAntiWandering.apiresult.ApiResultData;
import com.gs.SynAntiWandering.db.dto.ShortDto;
import com.gs.SynAntiWandering.model.ComboModel;
import com.gs.SynAntiWandering.model.listener.OnResultListener;
import com.gs.SynAntiWandering.view.IFilterView;

import java.util.List;

public class FilterPresenter extends BasePresenter<IFilterView> {
    private ComboModel comboModel = new ComboModel();

    public void combo(String typeKey) {
        comboModel.combo(typeKey, new OnResultListener() {
            @Override
            public void onSuccess(Object apiResult) {
                if (getView() != null) {
                    getView().onGetComboSuccess((ApiResultData<List<ShortDto>>) apiResult);
                }
            }

            @Override
            public void onFails(Exception e) {
                if (getView() != null) {
                    getView().onGetComboFails(e);
                }
            }
        }, new TypeToken<ApiResultData<List<ShortDto>>>() {
        }.getType());
    }
}
